package com.blog.nav.service.Impl;

import com.blog.nav.dao.NavigationMapper;
import com.blog.nav.entry.NavigationPO;
import com.blog.nav.service.NavigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class NavigationServiceImpl implements NavigationService {

    @Autowired
    private NavigationMapper navigationMapper;

    @Override
    public void add(NavigationPO navigationPO) {
        navigationMapper.insert(navigationPO);
    }

    @Override
    public List<NavigationPO> findNavByStatus(int status) {
        Example example = new Example(NavigationPO.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("status",status);
        return navigationMapper.selectByExample(example);
    }

    @Override
    public void deleteById(Long id) {
        navigationMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(NavigationPO navigationPO) {
        navigationMapper.updateByPrimaryKey(navigationPO);
    }
}
